package com.server.server_a10.controller;


import com.server.server_a10.entity.Inform;
import com.server.server_a10.entity.Room;
import com.server.server_a10.mapper.RoomMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


@RestController
public class RoomHandle {
    @Autowired
    RoomMapper roomMapper;
    @PostMapping(value = "/getRoomByHomeId")
    public Inform getRoomByHomeId(@RequestBody Map<String, Object> request){
        Inform inform = new Inform();

        int id = (int) request.get("id");
        List<Room> rooms = roomMapper.getRoomByHomeId(id);

        if (rooms==null){
            inform.setCode(100);
            inform.setMsg("这个房子家徒四壁，没有房间");
        }else {
            inform.setCode(200);
            inform.setData(rooms);
            inform.setMsg("房间信息已加载完毕");
        }

        return inform;
    }

}
